package sunwin.yoms.service.system;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import sunwin.yoms.comm.YomsException;
import sunwin.yoms.dao.NavigationGroupDao;
import sunwin.yoms.domain.system.NavigationGroupDomain;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by watson on 2015/7/30.
 */
@Service
public class NavigationGroupService {
    @Autowired
    private NavigationGroupDao navigationGroupDao;

    //查询
    public List<NavigationGroupDomain> getNavigationGroup(NavigationGroupDomain navigationGroupDomain) {
        List<NavigationGroupDomain> navigationGroupDomains = new ArrayList<NavigationGroupDomain>();
        navigationGroupDomains = navigationGroupDao.getDomainCollection(navigationGroupDomain);
        return navigationGroupDomains;
    }

    //id查询
    public NavigationGroupDomain getNavigationGroupById(int navigationGroupId) {
        return navigationGroupDao.getDomainById(navigationGroupId);
    }

    //总数量
    public int getNavigationGroupCount() {
        return navigationGroupDao.getDomainCount();
    }

    //增加
    public void addNavigationGroup(NavigationGroupDomain navigationGroupDomain) throws YomsException {
        if (navigationGroupDao.addDomain(navigationGroupDomain) != 1) {
            throw new YomsException("增加导航分组失败");
        }
    }

    //删除
    public void deleteNavigationGroup(NavigationGroupDomain navigationGroupDomain) throws YomsException {
        if (navigationGroupDao.deleteDomain(navigationGroupDomain) != 1) {
            throw new YomsException("删除导航分组失败");
        }
    }

    //更新
    public void upNavigationGroup(NavigationGroupDomain navigationGroupDomain) throws YomsException {
        if (navigationGroupDao.updateDomain(navigationGroupDomain) != 1) {
            throw new YomsException("更新导航分组失败");
        }
    }

}
